<link rel="stylesheet" href="../public/js/vendor/laydate/need/laydate.css">
<link rel="stylesheet" href="../public/js/vendor/laydate/skins/default/laydate.css">
<script src="../public/js/vendor/laydate/laydate.js"></script>
<link rel="stylesheet" href="../public/js/vendor/uploadify/mydemo/uploadify-demo.css">
<script src="../public/js/vendor/uploadify/jquery.uploadify.min.js"></script>
<div class="content_wrapper">

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i> 供应详情</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-horizontal" role="form" method="post" action="" data-validate="validate">
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">标题</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control" placeholder="" name="title" value="" disabled>
                                            </div>
                                            <!--<p class="col-sm-6 help-block">必填</p>-->
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">船号</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control" placeholder="" name="shipCode" value="" disabled>
                                            </div>
                                            <!--<p class="col-sm-6 help-block">必填</p>-->
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">手机号</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control" placeholder="" name="phone" value="" disabled>
                                            </div>
                                            <!--<p class="col-sm-6 help-block">必填</p>-->
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">存储方式</label>
                                            <div class="col-sm-4">
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" name="storageMode" value="0" >冰鲜
                                                    </label>
                                                </div>
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" name="storageMode" value="1">冻品
                                                    </label>
                                                </div>
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" name="storageMode" value="2">远洋
                                                    </label>
                                                </div>
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" name="storageMode" value="3">已加工
                                                    </label>
                                                </div>
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" name="storageMode" value="4">养殖
                                                    </label>
                                                </div>
                                            </div>
                                            <!--<p class="col-sm-6 help-block">如果是未通过，则此条新闻不在网站前台显示</p>-->
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">分类</label>
                                            <div class="col-sm-4">
                                                <select class="form-control" name="category">
                                                    <option value="0">请选择</option>
                                                    <option value="1">1</option>
                                                    <option value="2">2</option>
                                                    <option value="3">3</option>
                                                    <option value="4">4</option>
                                                    <option value="5">5</option>
                                                </select>
                                            </div>
                                            <p class="col-sm-6 help-block">必填</p>
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">规格价格信息</label>
                                            <div class="col-sm-4">
                                                <label>规格价格信息</label>
                                                <!--<input type="text" class="form-control" placeholder="标题" name="title">-->
                                            </div>
                                            <!--<p class="col-sm-6 help-block">必填</p>-->
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">交易地点</label>
                                            <div class="col-sm-4">
                                                <label>交易地点</label>
                                                <!--<input type="text" class="form-control" placeholder="标题" name="title">-->
                                            </div>
                                            <!--<p class="col-sm-6 help-block">必填</p>-->
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">产地:</label>
                                            <div class="col-sm-4">
                                                <label>产地</label>
                                                <!--<input type="text" class="form-control" placeholder="标题" name="title">-->
                                            </div>
                                            <!--<p class="col-sm-6 help-block">必填</p>-->
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">存储温度:</label>
                                            <div class="col-sm-4">
                                                <label>存储温度</label>
                                                <!--<input type="text" class="form-control" placeholder="标题" name="title">-->
                                            </div>
                                            <!--<p class="col-sm-6 help-block">必填</p>-->
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">包装说明:</label>
                                            <div class="col-sm-4">
                                                <label>包装说明</label>
                                                <!--<input type="text" class="form-control" placeholder="标题" name="title">-->
                                            </div>
                                            <!--<p class="col-sm-6 help-block">必填</p>-->
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">交易方式:</label>
                                            <div class="col-sm-4">
                                                <select class="form-control" name="category">
                                                    <option value="0">请选择</option>
                                                    <option value="1">1</option>
                                                    <option value="2">2</option>
                                                    <option value="3">3</option>
                                                    <option value="4">4</option>
                                                    <option value="5">5</option>
                                                </select>
                                            </div>
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">截止时间:</label>
                                            <div class="col-sm-4">

                                                <div class="form-group">
                                                    <input type="text" class="form-control" id="arrivaltime" value=""/>
                                                </div>

                                            </div>
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">发布时间:</label>
                                            <div class="col-sm-4">
                                                <div class="form-group">
                                                    <input type="text" class="form-control" id="sortTime" value=""/>
                                                </div>
                                            </div>
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">关注数:</label>
                                            <div class="col-sm-4">
                                                <label>关注数</label>
                                                <!--<input type="text" class="form-control" placeholder="标题" name="title">-->
                                            </div>
                                            <!--<p class="col-sm-6 help-block">必填</p>-->
                                        </div>
                                        <hr/>


                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">图片:</label>
                                            <div class="col-sm-4">
                                                <input type="button" id="uploadify1"/>

                                                <div class="upload-img-box">

                                                </div>
                                                <!--<div id="waitUploadNum"></div>-->
                                                <!--<div id="imageView"></div>-->
                                                <!--<input type="text" class="form-control" placeholder="标题" name="title">-->
                                            </div>
                                            <!--<p class="col-sm-6 help-block">必填</p>-->
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">备注:</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control" placeholder="备注" name="remark">
                                            </div>
                                            <!--<p class="col-sm-6 help-block">必填</p>-->
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">状态:</label>
                                            <div class="col-sm-4">
                                                <select class="form-control" name="statusId">
                                                    <option value="0">请选择</option>
                                                    <option value="1">1</option>
                                                    <option value="2">2</option>
                                                    <option value="3">3</option>
                                                    <option value="4">4</option>
                                                    <option value="5">5</option>
                                                </select>
                                            </div>
                                        </div>
                                        <hr/>

                                        <div class="form-group">
                                            <div class=" col-sm-12">
                                                <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
                                            </div>
                                        </div>

                                    </form>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>



<script>
    function validate($from) {
//        var title = $from.find('input[name="title"]');
//        if ($.trim(title.val()) == '') {
//            return '新闻标题不能为空';
//        }
        return true;
    }

    laydate({
        elem: '#sortTime',
        format: 'YYYY/MM/DD hh:mm:ss',
        istime: true,
        choose: function (datas) {
            console.log(datas);
        }
    });
    laydate({
        elem: '#arrivaltime',
        format: 'YYYY/MM/DD hh:mm:ss',
        istime: true,
        choose: function (datas) {
            console.log(datas);
        }
    });
    $(document).ready(function () {

        $("form").attr("action", common_conf.requestUrl+'supply/edit');

//       getSupplyDetail($("#editid").val());
        getSupplyDetail($.getUrlVar('id'));
        initPicUploadComponet();
    });


    function getSupplyDetail(id) {
        $.ajax({
            type: 'post',
            url: common_conf.requestUrl+'supply/detail',
            contentType : 'application/json;charset=UTF-8',
            cache: false,
            data: '{"id":'+id+'}',
            dataType: 'json',
            beforeSend: function () {
            },
            success: function (returnData) {
                if(forceLogin(returnData)) return;
                var obj=returnData;
                if(obj.state=="success"){
                    initFormData(obj.data);
                }else{
                    alert("获取失败");
                }
            },
            error: function () {
                alert("未找到模板");
            }
        });
    }

    function initFormData($supply) {
        $("input[name='title']").val($supply.title);
        $("input[name='shipCode']").val($supply.shipCode);
        $("input[name='phone']").val($supply.phone);

        $('form').append("<input type='hidden' name='id' value='"+$supply.id+"'>");
        $('input[name="storageMode"]').each(function(){
            if(this.value==$supply.storageMode){
                this.checked=true;
            }
        });

    }



</script>